<?php
	function alertDay($text,$color,$icon)
	{
		$colors = array
		(
			'red'=>'#ff0000',
			'yellow'=>'#FFFB00',
			'green'=>'#00ff00',
		);
		$icons = array
		(
			'family'=>'images/family_super_small.png',
			'business'=>'images/briefcase_super_small.png',
			'pleasure'=>'images/coffee_super_small.png',
		);
		return 
		'<HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" backgroundColor="'.$colors[$color].'" backgroundAlpha="0.3" cornerRadius="2" click="dispatchEvent(viewstack1, \'eventpreview\')">
			<Text text="'.$text.'"/>
			<Image source="'.$icons[$icon].'" width="20" height="20" />
		</HBox>';
	}
	function checkDayAlert($hour)
	{
		$events = array
		(
			13=>array('Call Boss','yellow','business'),
			15=>array('Watch football','green','pleasure'),
			17=>array('Pick up kids','yellow','family'),
			20=>array('Cook Dinner','red','family')
		);
		#$events = array();
		if(isset($events[$hour]))
		{
			return alertDay
			(
				$events[$hour][0],
				$events[$hour][1],
				$events[$hour][2]
			);
		}
		return '';
	}
?>
<Canvas label="Day view" width="100%" height="100%" horizontalAlign="center">
	<HBox width="95%" height="100%" horizontalAlign="center">
		<Grid borderStyle="none" width="95%" verticalGap="5" backgroundColor="#eeeeee" backgroundAlpha="0.5">
			<GridRow backgroundColor="#f0f0f0" width="100%">
				<GridItem width="12%"><Text text=""/></GridItem>
				<GridItem width="76%"><Text text="Today"/></GridItem>
				<GridItem width="12%"><Text text=""/></GridItem>
			</GridRow>
			<?php
				for($i=0;$i<=23;$i++)
				{
					?><GridRow <?php echo ($i%2)?'':'backgroundColor="#f0f0f0"'; ?> width="100%" backgroundAlpha="0.5">
						<GridItem width="12%" height="50"><Text text="<?php echo $i;?>:00"/></GridItem>
						<GridItem width="76%" height="50"><?php echo checkDayAlert($i) ?></GridItem>
						<GridItem width="12%" height="50"><Text text=""/></GridItem>
					</GridRow><?php
				}
			?>
		</Grid>
	</HBox>
</Canvas>